package cn.springboot.pioneermall.chat.container;

import javax.websocket.Session;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SessionContainer {
    private final static Map<String, Session> sessionMap = new ConcurrentHashMap<>();

    public static void addSession(String userId, Session session) {
        sessionMap.putIfAbsent(userId, session);
    }


    public static Session getSessionById(String userId) {
        if(userId==null) return null;
        return sessionMap.get(userId);
    }

    public static void removeSession(String userId) {
        sessionMap.remove(userId);
    }

}
